﻿using FileSystemCustomClasses.Framework;
using System;
using System.IO;
using System.Runtime.InteropServices;

namespace FileSystemCustomClasses
{
	public class FileItem : FileSystemItem
	{
		public string Extension { get; set; }
		public string RootName { get; set; }

		public FileItem(FileSystemInfo argCurrentItem):base(argCurrentItem)
		{
			FileInfo localInfo = new FileInfo(argCurrentItem.FullName);

			Name = localInfo.Name;
			Length = localInfo.Length;

			if (localInfo.Extension.Length > 0)
			{
				Extension = localInfo.Extension.Substring(1); //Extension starts after the dot
			}
			else
			{
				Extension = String.Empty;
			}

			RootName = localInfo.Name.Substring(0, localInfo.Name.Length - localInfo.Extension.Length); //End before the dot in the extension

			CreateDate = localInfo.CreationTime;
			ModifyDate = localInfo.LastWriteTime;
		}
	}
}